package com.sundae.smarthomedemo.Activitys;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.widget.ImageView;

import com.sundae.smarthomedemo.MyAppConfig;
import com.sundae.smarthomedemo.R;

import immortalz.me.library.TransitionsHeleper;
import immortalz.me.library.bean.InfoBean;
import immortalz.me.library.method.ColorShowMethod;

public class DeviceSelectActivity extends BaseActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_device_select);


        TransitionsHeleper.getInstance()
                .setShowMethod(new ColorShowMethod(R.color.grayColor,R.color.styleColor) {
                    @Override
                    public void loadCopyView(InfoBean bean, ImageView copyView) {
                        AnimatorSet set = new AnimatorSet();
                        set.playTogether(
                                ObjectAnimator.ofFloat(copyView,"rotation",0,180),
                                ObjectAnimator.ofFloat(copyView, "scaleX", 1, 0),
                                ObjectAnimator.ofFloat(copyView, "scaleY", 1, 0)
                        );
                        set.setInterpolator(new AccelerateInterpolator());
                        set.setDuration(duration / 4 * 5).start();
                    }

                    @Override
                    public void loadTargetView(InfoBean bean, ImageView targetView) {
                    }
                })
                .show(this,null);

        initView();
    }

    private void initView()
    {
        findViewById(R.id.device_select_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        findViewById(R.id.device_select_rsq).setOnClickListener(this);
        findViewById(R.id.device_select_gyg).setOnClickListener(this);
        findViewById(R.id.device_select_csq).setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent(DeviceSelectActivity.this , DeviceInfoActivity.class);
        intent.putExtra("isAdd" , true);
        switch (v.getId())
        {
            case R.id.device_select_rsq:
                intent.putExtra("deviceType" , MyAppConfig.rsq_type);
                break;
            case R.id.device_select_gyg:
                intent.putExtra("deviceType" , MyAppConfig.dfg_type);
                break;
            case R.id.device_select_csq:
                intent.putExtra("deviceType" , MyAppConfig.jsq_type);
                break;
        }
        startActivity(intent);
    }
}
